<?

class Mojito_Mail
{

	private static $_Config;
	
	public static function bootstrap(Zend_Config $Config)
	{
		self::$_Config=$Config;
	}
	
	public static function send ($account, array $args)
	{
		$config = array('auth'=>'login',
		'username'=>$account.'@'.self::$_Config->accounts->{$account}->domain,
		'password'=>self::$_Config->accounts->{$account}->password,'ssl'=>'tls','port'=>587);

		$Mail = new Zend_Mail();
		
		$Mail->setBodyText($args['body'],'UTF-8');
		$Mail->setBodyHtml(nl2br($args['body']),'UTF-8');
		$Mail->setFrom($account.'@'.self::$_Config->accounts->{$account}->domain, self::$_Config->accounts->{$account}->name);
		$Mail->addTo($args['to']['address'], $args['to']['name']);
		//$Mail->addBcc('michael@callisto.fm');
		$Mail->setSubject($args['subject']);
		$Mail->send(new Zend_Mail_Transport_Smtp(self::$_Config->accounts->{$account}->smtp, $config));
	}
}